package com.aaa.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface S_FrontTestDao {
    /**
     * 查出试卷名称
     * @param exam_id
     * @return
     */
    @Select("SELECT information_id FROM exam WHERE id=#{exam_id}")
    String selectExam(Integer exam_id);

    @Select("SELECT * FROM new_questions WHERE exam_id=#{exam_id}")
    List<Map> selQuestions(Integer exam_id);

    @Select("SELECT answer FROM new_questions WHERE id=#{id} AND exam_id=#{exam_id}")
    String getAnswer(Map map);

    @Select("SELECT COUNT(*) FROM exam_people WHERE exam_id=#{exam_id}")
    Integer getPeople(Integer exam_id);

    @Select("SELECT total_score FROM exam_scorce WHERE exam_id=#{exam_id}")
    List<Map> getSco(int exam_id);

    @Insert("INSERT INTO exam_scorce(exam_id,exam_people,total_score,average1) VALUES (#{exam_id},#{exam_people},#{total_score},#{average1})")
    void addScorce(Map map);

    @Update("UPDATE exam_scorce SET total_score=#{total_score},average1=#{average1}  WHERE exam_id=#{exam_id}")
    void updScorce(Map map);

    @Update("UPDATE exam_people SET state=2 WHERE id=#{id}")
    void updPeople(int id);

}
